<template>
  <el-container >
    <el-aside width="250px">
      <el-menu
        :default-active="activeIndex"
        router
      >
        <NavMenu :navMenus="menu.childs"></NavMenu>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header>
        <el-dropdown>
          <i class="el-icon-setting" style="margin-right: 20px"></i>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>查看</el-dropdown-item>
            <el-dropdown-item>新增</el-dropdown-item>
            <el-dropdown-item>删除</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
        <span>亲爱的{{user.username}}</span>
      </el-header>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
  import NavMenu from "@/components/menu/NavMenu"
  export default {

    components:{
      NavMenu:NavMenu,
    },
    data(){
      return{
        user:{
          "username":"longlog"
        },
        menu:{}
      }
    },
    created(){
      this.getMenu()
    },
    methods:{
      getMenu(){
        this.$axios.post('/menu/getMenu')
          .then(res=>{
            this.menu = res.data.data
          })
          .catch(err=>{
            this.$message({
              message:'获取数据错误',
              type: 'error',
              duration: 3000
            })
          })
      }
    }
  }
</script>
<style scoped>
  .el-header{
    background-color: #00142a;
    color: white;
    text-align: center;
    line-height: 50px;
    text-align: right;
    font-size: 20px;
  }

  .el-container{
    /*设置内部填充为0，几个布局元素之间没有间距*/
    padding: 0px;
    /*外部间距也是如此设置*/
    margin: 0px;
    /*统一设置高度为100%*/
    height: 700px;
  }

  .el-aside {
    background-color: #00142a;
    color: #333;
    text-align: center;
    line-height: 200px;
  }

  .el-image{
    top:50px;
    background-color: #E9EEF3;
    width: 500px;
    height: 501px;
  }

  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
</style>
